package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdAreacl;
import com.ruoyi.system.service.IBdAreaclService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地区分类Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@Controller
@RequestMapping("/system/areacl")
public class BdAreaclController extends BaseController
{
    private String prefix = "system/areacl";

    @Autowired
    private IBdAreaclService bdAreaclService;

    @RequiresPermissions("system:areacl:view")
    @GetMapping()
    public String areacl()
    {
        return prefix + "/areacl";
    }

    /**
     * 查询地区分类列表
     */
    @RequiresPermissions("system:areacl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BdAreacl bdAreacl)
    {
        startPage();
        List<BdAreacl> list = bdAreaclService.selectBdAreaclList(bdAreacl);
        return getDataTable(list);
    }

    /**
     * 导出地区分类列表
     */
    @RequiresPermissions("system:areacl:export")
    @Log(title = "地区分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BdAreacl bdAreacl)
    {
        List<BdAreacl> list = bdAreaclService.selectBdAreaclList(bdAreacl);
        ExcelUtil<BdAreacl> util = new ExcelUtil<BdAreacl>(BdAreacl.class);
        return util.exportExcel(list, "地区分类数据");
    }

    /**
     * 新增地区分类
     */
    @RequiresPermissions("system:areacl:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存地区分类
     */
    @RequiresPermissions("system:areacl:add")
    @Log(title = "地区分类", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BdAreacl bdAreacl)
    {
        return toAjax(bdAreaclService.insertBdAreacl(bdAreacl));
    }

    /**
     * 修改地区分类
     */
    @RequiresPermissions("system:areacl:edit")
    @GetMapping("/edit/{pkAreacl}")
    public String edit(@PathVariable("pkAreacl") String pkAreacl, ModelMap mmap)
    {
        BdAreacl bdAreacl = bdAreaclService.selectBdAreaclByPkAreacl(pkAreacl);
        mmap.put("bdAreacl", bdAreacl);
        return prefix + "/edit";
    }

    /**
     * 修改保存地区分类
     */
    @RequiresPermissions("system:areacl:edit")
    @Log(title = "地区分类", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BdAreacl bdAreacl)
    {
        return toAjax(bdAreaclService.updateBdAreacl(bdAreacl));
    }

    /**
     * 删除地区分类
     */
    @RequiresPermissions("system:areacl:remove")
    @Log(title = "地区分类", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bdAreaclService.deleteBdAreaclByPkAreacls(ids));
    }
}
